package com.qhy.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author qiuhongyu
 * @date 2020/9/25 17:31
 */
@SpringBootApplication
@MapperScan("com.qhy.springcloud.dao")
@EnableEurekaClient  //在服务启动后自动注册到eureka中，
public class ProviderApplication_8001 {
    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication_8001.class, args);
    }

    /**
     * 增加一个servlet，为了配合监控的使用，这串代码是固定的代码
     *
     * @return
     */
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean registrationBean
                = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
